<?php

/**
 * Created by PhpStorm.
 * User: lvze
 * Date: 2016/7/20
 * Time: 11:01
 */

namespace App\Services;

class IPSWechatHelper
{
    // 显示按钮
    public static function showButton($options)
    {
        if (empty($options) or empty($options['type']) or !in_array($options['type'], ['frame', 'link'])) {
            return '';
        }

        /**
         * 按钮权限
         if (empty($options['permission']) or !in_array($options['permission'], Cache::get('permission.role.' . auth()->user()->role->id))) {
                    return '';
         }
         */

        if ($options['type'] == 'link') {
            if (empty($options['text']) or empty($options['href'])) {
                return '';
            }
            return '<a class="'.(!empty($options['css'])?$options['css']:'').'" '.(!empty($options['confirm']) ? 'onclick="if(!confirm(\''.$options['confirm'].'\')){return false}"' : '').' href="'.$options['href'].'" '.(!empty($options['style']) ? 'style="'.$options['style'].'"' : '').'>'.$options['text'].'</a>';
        }
    }

}